package arch.dao.impl.archive;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.springframework.jdbc.core.BatchPreparedStatementSetter;

import arch.domain.archive.ArchiveDefinition;
/**
 * 
 * @author zhangxue
 *
 */
public class ArchdefFieldsBatchPreparedStatementSetter implements
		BatchPreparedStatementSetter {
	private ArchiveDefinition archdef;
	public ArchdefFieldsBatchPreparedStatementSetter(ArchiveDefinition ad){
		archdef = ad;
	}

	public int getBatchSize() {
		if(archdef!=null&&archdef.getFields()!=null){
			return archdef.getFields().size();
		}else{
			return 0;
		}
		
	}

	public void setValues(PreparedStatement ps, int i) throws SQLException {
		if(archdef!=null&&archdef.getFields().size()>0){
			ps.setInt(1, archdef.getId());
			ps.setInt(2, archdef.getFields().get(i).getId());
			ps.setString(3, archdef.getFields().get(i).getDefaultValue());
			ps.setString(4, archdef.getFields().get(i).getRestriction());
		}
		
	}

}
